# 作业先完成，再完美
# 用类封装一个MyMath类, 实现加, 减, 乘, 除, 幂, 开方
class MyMath:
    # 加
    def add(self, a, b):
        return a + b
    # 减
    def reduce(self, a, b):
        return a - b
    # 乘
    def multip(self, a, b):
        return a * b
    # 除
    def division(self, a, b):
        return a / b
    # 幂
    def power(self, a, b):
        c = a
        b -= 1
        while b:
            c *= a
            b -= 1
        return c
    # 开方
    def sqrt(self, a, b):
        return a ** (1/b)


myMath = MyMath()
print(myMath.add(1, 2))
print(myMath.reduce(1, 2))
print(myMath.multip(1, 2))
print(myMath.division(1, 2))
print(myMath.power(3, 2))
print(myMath.sqrt(3, 2))

# 自由课题, 大家按自己的想法, 将身边的事物抽象出一个类, 并创建多个实例

class Humanity(object):
    head = 1
    feet = 2
    hands = 2
    def __init__(self, gender):
        self.gender = gender
        print(f"Ta的性别是:{self.gender}")

male = Humanity("男")
female = Humanity("女")

# 创建多个继承作业2父类的子类

class Teacher(Humanity):
    def __init__(self, profession):
        self.profession = profession
        print(f"Ta是个{self.profession}老师")

math = Teacher('数学')

class Doctors(Humanity):
    def __init__(self, subject):
        self.subject = subject
        print(f"Ta是个{self.subject}医生")

ped = Doctors('儿科')
